package com.ck.server.controller.dict;

import com.ck.common.constant.AjaxResult;
import com.ck.common.core.BaseController;
import com.ck.common.entity.SysDictData;
import com.ck.common.utils.txt.StringUtils;
import com.ck.system.service.SysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author changk
 * @date 2024/11/21 17:04
 * desc:数据字典信息
 */
@RestController
@RequestMapping("/system/dict/data")
public class SysDictDataController extends BaseController {
    @Autowired
    private SysDictTypeService dictTypeService;

    /**
     * 根据字典类型查询字典数据信息
     * @param dictType
     * @return
     */
    @GetMapping(value = "/type/{dictType}")
    public AjaxResult dictType(@PathVariable String dictType)
    {
        List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
        if (StringUtils.isNull(data))
        {
            data = new ArrayList<SysDictData>();
        }
        return success(data);
    }
}
